package com.qfedu.menu.controller;

import com.qfedu.common.R;
import com.qfedu.menu.pojo.Menu;
import com.qfedu.menu.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @GetMapping
    public R<List<Menu>> getUserMenus(HttpSession session){
        String username = (String) session.getAttribute("username");
        return R.ok(menuService.getUserMenus(username));
    }
}
